<?php
//**************************************************************************
//
//            (C) Okulov Rostislav, 2011
//
//**************************************************************************

/*
 ***************************************************************************
 *                                                                         *
 *   This source is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This code is distributed in the hope that it will be useful, but      *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 *   General Public License for more details.                              *
 *                                                                         *
 *   A copy of the GNU General Public License is available on the World    *
 *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
 *   obtain it by writing to the Free Software Foundation,                 *
 *   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.        *
 *                                                                         *
 */
 
if(!function_exists('bbcode')) {
   function bbcode($data) {
      $input = array('/\[blue\](.*?)\[\/blue\]/is',
                     '/\[green\](.*?)\[\/green\]/is',
                     '/\[code=(.*?)\](.*?)\[\/code\]/is',
                     '/\[h\](.*?)\[\/h\]/is',
                     '/\[b\](.*?)\[\/b\]/is',
                     '/\[i\](.*?)\[\/i\]/is',
                     '/\[u\](.*?)\[\/u\]/is',
                     '/\[img\](.*?)\[\/img\]/is',
                     '/\[url\](.*?)\[\/url\]/is',
                     '/\[url\=(.*?)\](.*?)\[\/url\]/is',
                     //'/\r?\n/',
                     '/\t(.*?)\t/is',
                     '/\[list\](.*?)\[\/list\]/is',
                     '/\[p\](.*?)\[\/p\]/is',
                     '/\[\*\](.*?)\;/is'//,
                     //'/\<(.*?)/is'
                    );
 
      $output = array('<br /><span style="color:blue;">$1</span>',
                      '<br /><br /><span style="color:green;">$1</span>',
                      '<pre class="brush: $1;\">$2</pre>',
                      '<h1>$1</h1>',
                      '<strong>$1</strong>',
                      '<em>$1</em>',
                      '<u>$1</u>',
                      '<p><img align="center" src="$1" /></p>',
                      '<a href="$1">$1</a>',
                      '<a href="$1">$2</a>',
                      //'<br />',
                      '<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$1</p>',
                      '<ul type="disc">$1</ul>',
                      '<p>$1</p>',
                      '<li>$1</li>'//,
                      //'&lt;'
                     );
 
      $rtrn = preg_replace ($input, $output, $data);
 
      return $rtrn;
   }
}

if(!function_exists('comment_bbcode')) {
   function comment_bbcode($data) {
      $input = array('/\[b\](.*?)\[\/b\]/is',
                     '/\[i\](.*?)\[\/i\]/is',
                     '/\[u\](.*?)\[\/u\]/is'
                    );
 
      $output = array('<strong>$1</strong>',
                      '<em>$1</em>',
                      '<u>$1</u>'
                     );
 
      $rtrn = preg_replace ($input, $output, $data);
 
      return $rtrn;
   }
}
?>
